home *** CD-ROM | disk | FTP | other *** search
- ' SysEnvirons and ADB Demo
- ' ©1989 MacTutor
- ' by Dave Kelly
- ' ZBasic 5.0
- '
- '*******************************************************************
- ' First check the System Environments
- ' To do this the SYSENVIRONS function needs to be modified to work
- ' Replace old SYSENVIRONS with D0.W=FN SYSENVIRONS(D0.L, A0.L)
- '*******************************************************************
- WINDOW OFF
- COORDINATE WINDOW
- 'Find out screen size.
- CALL GETWMGRPORT(WMgrPort&)
- PortTop=PEEK WORD(WMgrPort&+8)
- PortLeft=PEEK WORD(WMgrPort&+10)
- PortBottom=PEEK WORD(WMgrPort&+12)
- PortRight=PEEK WORD(WMgrPort&+14)
-
- WINDOW 1,"Main Window",(10,44)-(PortRight-4,PortBottom-4),1
- 'Bring window to the front (necessary under Multifinder)
- Wptr&=WINDOW(14)
- CALL SELECTWINDOW(Wptr&)
- ' Set up SysEnvRec
- DIM environsVersion,machineType, systemversion,processor,hasFPU,keyBoardType,atDrvrVersNum,sysVRefNum
- OSErr%=FN SYSENVIRONS(1,VARPTR(environsVersion))
- LONG IF OSErr%=0
- PRINT "Environment Version:";environsVersion
- PRINT "Machine Type:";
- SELECT machineType
- CASE 0
- PRINT "new version of Macintosh"
- CASE 1
- PRINT "Macintosh 512K enhanced"
- CASE 2
- PRINT "Macintosh Plus"
- CASE 3
- PRINT "Macintosh SE"
- CASE 4
- PRINT "Macintosh II"
- CASE -1
- PRINT "Macintosh with 64K ROM"
- CASE -2
- PRINT "Macintosh XL"
- END SELECT
- PRINT "System Version:";LEFT$(HEX$(systemversion),2);".";RIGHT$(HEX$(systemversion),2)
- PRINT "Processor:";
- SELECT processor
- CASE 0
- PRINT "new processor"
- CASE 1
- PRINT "MC68000 processor"
- CASE 2
- PRINT "MC68010 processor"
- CASE 3
- PRINT "MC68020 processor"
- END SELECT
- b$="&X"+RIGHT$(BIN$(hasFPU),8)
- hasColorQD=VAL(b$)
- b$="&X"+LEFT$(BIN$(hasFPU),8)
- hasFPU=VAL(b$)
- PRINT "Has Floating Point Coprocessor:";
- IF hasFPU=1 THEN PRINT "Yes" ELSE PRINT "No"
- PRINT "Has Color QuickDraw:";
- IF hasColorQD=1 THEN PRINT "Yes" ELSE PRINT "No"
- PRINT "Keyboard Type:";
- SELECT keyBoardType
- CASE 0
- PRINT "Macintosh Plus keyboard with keypad"
- CASE 1
- PRINT "Macintosh keyboard"
- CASE 2
- PRINT "Macintosh keyboard and keypad"
- CASE 3
- PRINT "Macintosh Plus keyboard"
- CASE 4
- PRINT "Apple extended keyboard"
- CASE 5
- PRINT "standard Apple Desktop Bus keyboard"
- CASE ELSE
- PRINT "don't recognize this one!"
- END SELECT
- PRINT "AppleTalk Driver version:";atDrvrVersNum
- PRINT "Working Directory Volume Reference #:";sysVRefNum
- XELSE
- PRINT "Error =";OSErr%
- END IF
- '*******************************************************************
- ' Now Read the ADB
- ' This routine turns on and off the
- ' lights of the Extended keyboard
- ' ADB calls and functions need to be added to ZBasic 5.0
- ' using the Toolbox mover program.
- '*******************************************************************
- '
- IF keyBoardType<>4 THEN END
- DIM DeviceType%,ServiceAddress&,DataAddress&:' GETINDADB Parmeter block
- DIM buffer%(2)
- bufferptr&=VARPTR(buffer%(0))
- compRoutptr&=0
- Datablkptr&=0' ADBOP Parameter block
-
- numberofADBdevices=FN COUNTADBS
- PRINT "There are";numberofADBdevices;"ADB devices present."
- IF numberofADBdevices=0 THEN STOP
- FOR i%=1 TO numberofADBdevices
- ADBAdd%=FN GETINDADB(VARPTR(DeviceType%),i%)
- b$="&X"+RIGHT$(BIN$(DeviceType%),8)
- OrgADBAddress%=VAL(b$)
- b$="&X"+LEFT$(BIN$(DeviceType%),8)
- DeviceType%=VAL(b$)
- LONG IF ADBAdd%=2 'Got the address for the Extended Keyboard
- Talk%=&H2E:' Talk command
- Listen%=&H2A:' Listen command
- Flush%=&H21:' Flush command
- PRINT "Press any key to continue..."
- DO
- X$=INKEY$
- GOSUB "MagicLights"
- UNTIL X$<>""
- END IF
- NEXT i%
- LONG IF X$=""
- PRINT "Press any key to continue..."
- DO
- X$=INKEY$
- UNTIL X$<>""
- END IF
- END
-
- "MagicLights"
- GOSUB "Togglelightson"
- GOSUB "Delay"
- GOSUB "Togglelightsoff"
- GOSUB "Delay"
- GOSUB "Togglelightson"
- GOSUB "Delay"
- GOSUB "Togglelightsoff"
- GOSUB "Delay"
- RETURN
-
- "Togglelightson"
- compRoutptr&=ServiceAddress&:Datablkptr&=DataAddress&
- 'This call reads register 2 of the ext. keyboard.
- OSErr%=FN ADBOP(VARPTR(bufferptr&),Talk%)
- GOSUB "Delay"
- buffer%(1)=&HF800
- 'The next call writes register 2 back to
- 'the extended keyboard. For some reason the register is not
- 'being written back to the keyboard. See Pascal version.
- OSErr%=FN ADBOP(VARPTR(bufferptr&),Listen%)
- RETURN
-
- "Togglelightsoff"
- OSErr%=FN ADBOP(VARPTR(bufferptr&),Flush%)
- RETURN
-
- "Delay"
- T1&=FN TICKCOUNT
- DO
- T&=FN TICKCOUNT
- UNTIL T&-T1&=20
- RETURN
-
-
-